<?php

interface iTwitterAuthDTO {}

class dtoTwitterAuth implements iTwitterAuthDTO
{
	public $oauth_token         = NULL;
	public $oauth_token_secret  = NULL;

	public $access_token        = FALSE;

	public $user_id             = NULL;
	public $screen_name         = NULL;
	public $name                = NULL;
	public $utc_offset          = NULL;


	const SESSION_TW_AUTH_DTO   = 'dto_twitter_auth';

	public static function factory(dtoTwitterAuth $paramTwAuthDTO = NULL)
	{
		static $twAuthDTO = NULL;

		// save
		if ($paramTwAuthDTO)
		{
			$_SESSION[self::SESSION_TW_AUTH_DTO] = serialize($paramTwAuthDTO);
			return;
		}

		// get
		if ($twAuthDTO)
		{
			return $twAuthDTO;
		}
		else if (array_key_exists(self::SESSION_TW_AUTH_DTO, $_SESSION))
		{
			$twAuthDTO = unserialize($_SESSION[self::SESSION_TW_AUTH_DTO]);

			if ($twAuthDTO instanceof iTwitterAuthDTO)
				return $twAuthDTO;
		}

		return $twAuthDTO = new dtoTwitterAuth();
	}
}

# EOF
